#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1;
const int M = 1e9+7;



int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int res = -1;
    for (int i = a; i <= b; i++) {
        if (i%c == 0) {
            res = i;
            break;
        }
    }
    cout << res << endl;
    return 0;
}